﻿using System;
using System.Collections.Generic;
using System.Linq;
using BusinessObjects;

namespace DataLayer
{
    public partial class UserRepository
    {
        /// <summary>
        /// Retrieve an User by their user name
        /// </summary>
        /// <param name="userName">The username of the <see cref="User"/> to retrieve</param>
        /// <returns>A <see cref="User"/> object</returns>
        public BusinessObjects.User FindUser(string userName)
        {
            User retObject;

            using (dB = new PracticeSimpleDataContext())
            {
                retObject = (from x in dB.Users where x.Username == userName select x).SingleOrDefault();
            }

            return ConvertToBusinessObject(retObject);
        }
    }
}
